/*Copyright (C) 2013-2021 LZE*/
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define mod 1000000007
#define eps 1e-6
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 1000010;
ll n;
struct TrieNode{
    ll letter[27],ch,word;
    ll father,fail;
    TrieNode(){}
}Trie[N];
ll node_num = 0;
void insert(string str){
    ll len = str.length();
    ll step = 0; // root
    ll p = 0;
    ll letter;
    while(p < len){
        letter = str[p] - 'a';
        if(Trie[step].letter[letter] != 0){
            step = Trie[step].letter[letter];
        }
        else{
            Trie[step].letter[letter] = ++node_num;
            Trie[node_num].father = step;
            Trie[node_num].ch = letter;
            step = node_num;
        }
        p++;
    }
    Trie[step].word++;
}
void getFail(){
    queue<ll> q;
    for(int i = 0;i < 26;i++){
        if(Trie[0].letter[i] != 0){
            // cout << Trie[0].letter[i] << endl;
            q.push(Trie[0].letter[i]);
        }
    }
    // q.push(0);
    while(!q.empty()){
        ll p = q.front(); q.pop();
        // cout << p << " ";
        // if(p != 0 && Trie[Trie[p].father].fail != Trie[p].father){
        //     Trie[p].fail = Trie[Trie[Trie[p].father].fail].letter[Trie[p].ch];
        //     if(Trie[p].fail == 0){
        //             Trie[Trie[Trie[p].father].fail].letter[Trie[p].ch] = p;
        //     }
        // }
        for(ll i = 0;i < 26;i++){
            if(Trie[p].letter[i] != 0){
                Trie[Trie[p].letter[i]].fail = Trie[Trie[p].fail].letter[i];
                // cout << i << " " << Trie[p].letter[i] << " " << Trie[p].fail << " " << Trie[Trie[p].fail].letter[i];
                q.push(Trie[p].letter[i]);
            }
             else Trie[p].letter[i] = Trie[Trie[p].fail].letter[i];
        }
        // cout << endl;
    }
    Trie[0].fail = 0;
}
ll query(string str){
    ll len = str.length();
    ll p = 0;
    ll ans = 0;
    ll letter;
    ll step = 0; // root
    while(p < len){
        letter = str[p] - 'a';
        step = Trie[step].letter[letter];
        for(ll i = step;i != 0 && Trie[i].word != -1;i = Trie[i].fail){
            ans += Trie[i].word;
            Trie[i].word = -1;
        }
        p++;
    }
    return ans;
}
int main() {
    string pattern,text;
    scanf("%lld",&n);
    for(ll i = 1;i <= n;i++){
        cin >> pattern;
        insert(pattern);
    }
    getFail();
    // for(ll i = 0;i <= node_num;i++){
    //     cout << char(Trie[i].ch + 'a') << " " << Trie[i].fail << " " << Trie[i].father << " " << Trie[i].word << endl;
    //     cout << Trie[i].father << " " << i << " " << char(Trie[i].ch + 'a') << endl;
    // }
    cin >> text;
    printf("%lld\n",query(text));
	return 0;
}